//
//  RootViewController.m
//  One Day
//
//  Created by lanou on 16/1/11.
//  Copyright © 2016年 小明. All rights reserved.
//

#import "WTRootViewController.h"
#import "WTMineMainViewController.h"
#import "WTJokeMainViewController.h"
#import "WTMilitaryViewController.h"
#import "WTRadioMainViewController.h"


@interface WTRootViewController ()

@end

@implementation WTRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addViewControllerClass:[WTMilitaryViewController class] title:@"军事" imageName:@"junshi" selectImageName:@"junshi1"];
    [self addViewControllerClass:[WTJokeMainViewController class] title:@"笑话"imageName:@"xiaohua" selectImageName:@"xiaohua1"];
    [self addViewControllerClass:[WTRadioMainViewController class] title:@"电台" imageName:@"radio" selectImageName:@"radio1"];
    [self addViewControllerClass:[WTMineMainViewController class] title:@"我的" imageName:@"mine" selectImageName:@"mine1"];
    
    self.selectedIndex = 0;
    self.tabBar.tintColor = [UIColor blueColor];
    self.tabBar.barTintColor = [UIColor whiteColor];
    
    // Do any additional setup after loading the view.
}

// 声明一个方法,这个方法用来,添加Controller
- (void)addViewControllerClass:(Class)class title:(NSString *)title imageName:(NSString *)imageName selectImageName:(NSString *)selectImageName
{
    UIViewController *viewVC = [[class alloc]init];
    UINavigationController *naVC = [[UINavigationController alloc]initWithRootViewController:viewVC];
    naVC.tabBarItem.title = title;
    naVC.tabBarItem.image = [UIImage imageNamed:imageName];
    
    naVC.tabBarItem.selectedImage = [UIImage imageNamed:selectImageName] ;
    [self addChildViewController:naVC];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
